<%= javascript_include_tag "prototype" %>
<%= javascript_include_tag "util" %>
<script language="JavaScript" type="text/JavaScript">
        function checkNull(flag, msg_id, obj_id, msg_text){
                if (flag) {
                        if ($(obj_id).value == "")
                        {
                                $(msg_id).innerText = msg_text;
                                $(msg_id).style.display = "block";
                                return false;
                        }
                        else return true;
                }
                else {
                        $(msg_id).style.display = "none";
                }
        }

	function checkForm(){
		return checkNull(true,'id_name','role_name','请输入角色名称');
	}
</script>
<h1>角色管理 - <span id="secondHeading">增加角色</span></h1>
<%= form_tag({}, :id=>"input-form") %>
<TABLE border="0" id="INPUT_TABLE">
	<TR>
		<TD colspan="2">
			<% if @flash[:notice] -%>
			<div id="notice"><%= @flash[:notice] %></div>
			<% end -%>
		</TD>
	</TR>
	<TR>
		<td>角色名：</td>
                <td><%= text_field("role", "name",:size=>"30", :maxlength=>"20", :onfocus=>"checkNull(false,'id_name')", :onblur=>"checkNull(true,'id_name',this.id,'请输入角色名称')") %>          <em>*</em><div class="redNsg" id="id_name" style="display:none;"></div></td>
	</tr>
	<tr>
		<td>所属部门：</td>
		<td><%=collection_select(:role, :department_id, @departments, :id, :name)%></td>
	</tr>
	<tr>
		<td>备注：</td>
		<td><%= text_area("role","memo",:cols=>"50",:rows=>"5")%></td>
	</tr>
	<tr>
		<td colspan="2" align="right"><input type="submit" value="添加" class="sub" onclick="javascript:return checkForm();"/>&nbsp;OR&nbsp;<input type="reset" value="重新填写" class="cal"></td>
	</TR>
</TABLE>
<p class="note"> <strong class="alert">注意：</strong><br/>
 一、有 <em>*</em> 标记的是必填项。
 </p>
<%= end_form_tag %>	
